#include "CFDPostGUIDialogBase.h"
#include "CFDPostGUIDialogManager.h"
#include "GUIFrame/MainWindow.h"

#include "OperatorsInterface/GraphEventOperator.h"
#include "PostGraphAdaptor/PostGraphObjectManager.h"
#include "FITK_Interface/FITKInterfaceCFDPost/FITKCFDPostData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"

namespace GUI {
    CFDPostGUIDialogBase::CFDPostGUIDialogBase(Core::FITKActionOperator* oper, QString dialogTitle, QWidget* parent) :
        Core::FITKDialog(parent), _oper(oper) {
        _postDataManager = FITKAPP->getGlobalData()->getPostData<Interface::FITKCFDPostData>()->getPostDataManager();
        _postGraphManager = Interface::PostGraphObjectManager::getInstance();
        _mainWin = dynamic_cast<MainWindow*>(FITKAPP->getGlobalData()->getMainWindow());

        CFDPostGUIDialogManager::getInstance()->dialogCreated(this, dialogTitle);
    }

    // CFDPostGUIDialogBase::CFDPostGUIDialogBase(EventOper::ParaWidgetInterfaceOperator* oper, QString dialogTitle, QWidget* parent) :
    //     Core::FITKDialog(parent), _oper(oper) {
    //     _postDataManager = FITKAPP->getGlobalData()->getPostData<Interface::FITKCFDPostData>()->getPostDataManager();
    //     _postGraphManager = Interface::PostGraphObjectManager::getInstance();
    //     _mainWin = dynamic_cast<MainWindow*>(FITKAPP->getGlobalData()->getMainWindow());

    //     CFDPostGUIDialogManager::getInstance()->dialogCreated(this, dialogTitle);
    // }

    CFDPostGUIDialogBase::~CFDPostGUIDialogBase() {
        // 通知管理器对话框已销毁
        CFDPostGUIDialogManager::getInstance()->dialogDestoried(this);
    }

    void CFDPostGUIDialogBase::reRender() {
        EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("OperGraphPreprocess");

        if (graphOper == nullptr)return;

        graphOper->reRender();
        //EventOper::CFDPostGraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::CFDPostGraphEventOperator>("OperGraphPreprocess");
    }
}
